package com.gmako.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gmako.dao.BaseDAO;
import com.gmako.entity.Businessinfo;
import com.gmako.entity.Userinfo;
import com.gmako.service.UserinfoService;

@Service
public class UserinfoServiceImpl implements UserinfoService{
	@Autowired
	private BaseDAO baseDAO;
	public Userinfo userLogin(String username, String pwd) {
		String hql = "from Userinfo where useremail = '"+username +"' and pwd='"+pwd+"'";
		return (Userinfo)baseDAO.loadObject(hql);
	}
	
	/**
	 * 根据一个条件获取另一个信息
	 * 根据用户ID 获取商家ID
	 */
	public Businessinfo businessinfo(int uid){
		String hql = "from Businessinfo where uid ="+uid;
		return (Businessinfo)baseDAO.loadObject(hql);
	}
	
	/**
	 * 查询商家信息是否上传
	 * @author yezhenchi
	 * @param name
	 */
	public int findBus(int uid){
		String hql = "Select count(id) from Businessinfo where uid= "+uid;
		long tag = (Long)baseDAO.loadObject(hql);
		if(tag==0){
			return 0;
		}
		else
			return 1;
	}

}
